package com.bjsxt.homework3;

public class Test3 {

    public static void main(String[] args) throws Exception {

        final MyContainer c = new MyContainer();

        for (int i = 0; i < 3; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int m = 0; m < 10; m++) {
                        c.add(new Object());
                    }
                }
            }, "addThread" + i).start();
        }

        Thread.sleep(10);

        for (int j = 0; j < 3; j++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    for (int n = 0; n < 10; n++) {
                        System.out.println(Thread.currentThread().getName() + " get " + c.get(0));
                    }
                }
            }, "getThread" + j).start();

        }
    }
}
